#ifndef _RING_MEM_H_
#define _RING_MEM_H_

#include <iostream>
#include <string.h>

#define ARR_SIZE(arr) (sizeof(arr) / sizeof(arr[0]))

class RingMem {
public:
  explicit RingMem(size_t size);
  ~RingMem();

  bool IsEmpty() const;
  bool IsFull() const;
  void PushData(const char *data, size_t num);
  void PopData(char *data, size_t num);
  void ReadData(char *data, size_t num);
  size_t get_value() const;
  size_t get_use() const;

  // for debug
  void printf_mem();
  bool is_same(size_t num, char *data, size_t r, size_t w, size_t use);
  void set_arr(char value);
  void set_w(size_t idx);
  void set_r(size_t idx);
  void set_use(size_t idx);
  void set_r_w_user(size_t r, size_t w, size_t use);
  size_t get_w() ;
  size_t get_r();
  size_t get_use();

private:
  char *addr_ = nullptr;
  size_t total_size_ = 0;
  size_t pos_w_ = 0;
  size_t pos_r_ = 0;
  size_t use_ = 0;
};

#endif  // endif _RING_MEM_H_
